package com.top.dao;

import com.top.entiy.User;
import com.top.jdbc.DatabaseConnection;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.List;
import java.util.Set;

/**
 * @Author:
 * @DateTime: 2023/12/8 21:52
 * @Description: TODO
 */
public class UserDao extends AbstractDAO implements IDAO<Integer, User> {


    public boolean doLogin(User user) throws SQLException {
        boolean flag = false;
        String sql = "SELECT * FROM `user` WHERE username = ? and `password` = ? AND state = 1";
        statement = super.conn.prepareStatement(sql);
        statement.setString(1,user.getUsername());
        statement.setString(2,user.getPassword());
        ResultSet rs = statement.executeQuery();
        if(rs.next()){
            flag = true;
        }
        return flag;
    }


    @Override
    public boolean doCreate(User vo) throws SQLException {
        return false;
    }

    @Override
    public boolean doUpdate(User vo) throws SQLException {
        return false;
    }

    @Override
    public boolean doRemove(Integer id) throws SQLException {
        return false;
    }


    @Override
    public User findById(Integer id) throws SQLException {
        return null;
    }

    @Override
    public List<User> findAll() throws SQLException {
        return null;
    }

    @Override
    public List<User> findAllBySplit(String column, String keyWord, Integer currentPage, Integer lineSize) throws SQLException {
        return null;
    }

    @Override
    public Integer getAllCount(String column, String keyWord) throws SQLException {
        return null;
    }
}
